Standards as Constraints
In other databases or languages, you are able to join properties or perform aggregations. We can do this in Standard by creating a constraint of type standard
.
truck: TRCK: @VHL {
protected owner Standard @PER OWNR *
protected double max_weight MXWGHT
}
Now when accessing the owner
constraint, you can access it like @USR
or OWNR
. When this record is saved, the constraint value is the record id of the parent Standard record.
#Get Trucks where vehicle model is 'Tesla', limit 1
foundTruck [TRCK] <VHL.MK "Tesla" 1>
print foundTruck OWNR FNAME #Prints truck owner's first name
print foundTruck owner firstname #Also prints truck owner's first name
print foundTruck USR firstname #Again
If your Standard references the same Standard in more than one constraint, Standard will select the first constraint that uses that Standard.
truck: TRCK: @VHL {
protected owner Standard @PER OWNR *
protected driver Standard @PER DRVR *
}
#Ini empty object
truck @TRCK
print truck PER firstname #Will only ever print the owner's firstname
print truck driver firstname #Now we print driver's firstname